package com.ds.infrastructure.hyperspace.console.model.request.handler;

import com.ds.infrastructure.hyperspace.console.config.validation.EnumValue;
import com.ds.infrastructure.hyperspace.console.entity.enums.TbHandlerEnum;
import com.ds.infrastructure.hyperspace.console.entity.enums.TbPublicEnum;
import com.ds.infrastructure.hyperspace.console.entity.table.TbHandler;
import com.ds.infrastructure.hyperspace.console.model.request.form.PageForm;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @author: yaozhendong
 * @create: 2019-09-20 19:46
 **/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class ListHandlerForm extends PageForm {

    @ApiModelProperty(value = "Handler类型(非必填):1=preFlow;2=postFlow;3=preFlow|postFlow(通用处理器);", example = "3")
    @EnumValue(value = TbHandlerEnum.HANDLER_TYPE.class, nullable = true)
    private Integer handlerType;

    public static TbHandler toEntity(ListHandlerForm form) {
        TbHandler tbHandler = new TbHandler();
        tbHandler.setHandlerType(form.getHandlerType());
        tbHandler.setGmtIsDeleted(TbPublicEnum.GMD_IS_DEL.NO.code);
        return tbHandler;
    }
}
